local zhuiyu = fk.CreateSkill {
  name = "th_zhuiyu",
}

zhuiyu:addEffect("viewas", { ---FIXME: 应为手杀锁视
  anim_type = "offensive",
  pattern = "slash",
  prompt = "#th_zhuiyu",
  mute_card = false,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select):getMark("@@th_zhuiyu-inhand") > 0
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("slash")
    card:addSubcards(cards)
    card.skillName = zhuiyu.name
    return card
  end,
  enabled_at_response = function (self, player, response)
    return not response
  end,
})
zhuiyu:addEffect(fk.AskForRetrial, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(zhuiyu.name) and data.card and data.card.color == Card.Black and #player.room.draw_pile > 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, {
      skill_name = zhuiyu.name,
      prompt = "#th_zhuiyu-invoke:::" .. data.reason .. ":" .. data.card:toLogString()
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local orig = data.card.id
    local card = Fk:getCardById(room.draw_pile[1])
    room:changeJudge({
      card = card,
      player = player,
      data = data,
      skillName = zhuiyu.name,
      exchange = true
    })
    room:setCardMark(Fk:getCardById(orig, true), "@@th_zhuiyu-inhand", 1)
  end,
})
zhuiyu:addEffect("targetmod", {
  bypass_times = function(self, player, skill, scope, card, to)
    return card and table.contains(card.skillNames, zhuiyu.name)
  end
})
zhuiyu:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return card and card:getMark("@@th_zhuiyu-inhand") ~= 0
  end,
  prohibit_response = function(self, player, card)
    return card and card:getMark("@@th_zhuiyu-inhand") ~= 0
  end
})

Fk:loadTranslationTable{
  ["th_zhuiyu"] = "坠雨",
  [":th_zhuiyu"] = "一名角色的黑色判定牌生效前，你可以用牌堆顶一张牌代替之并获得原判定牌（只能当无次数限制的【杀】使用）。",

  ["#th_zhuiyu"] = "坠雨：将“坠雨”牌当无次数限制的【杀】使用",

  ["#th_zhuiyu-invoke"] = "坠雨：你可以用牌堆顶一张牌代替之并获得 %arg 判定的 %arg2 ，这张牌只能当无次数限制的【杀】使用",

  ["@@th_zhuiyu-inhand"] = "坠雨",
}

return zhuiyu